﻿@model IEnumerable<BackupDBLog>

@{
    ViewData["Title"] = "备份管理";
}

<h2>@ViewData["Title"]</h2>
<div class="container mt-3">
    @if (TempData["SuccessMessage"] != null)
    {
        <div class="alert alert-success alert-dismissible fade show" role="alert">
            @TempData["SuccessMessage"]
            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
        </div>
    }

    @if (TempData["ErrorMessage"] != null)
    {
        <div class="alert alert-danger alert-dismissible fade show" role="alert">
            @TempData["ErrorMessage"]
            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
        </div>
    }
</div>

<p>
    <a asp-action="Create" class="btn btn-primary">
        <i class="bi bi-plus-circle"></i> 新建备份
    </a>
</p>

<table class="table table-striped table-hover">
    <thead class="table-dark">
        <tr>
            <th>@Html.DisplayNameFor(model => model.FilePath)</th>
            <th>@Html.DisplayNameFor(model => model.CreatedTime)</th>
            <th>操作</th>
        </tr>
    </thead>
    <tbody>
        @foreach (var item in Model)
        {
            <tr>
                <td class="text-truncate" style="max-width: 300px;">
                    @Html.DisplayFor(modelItem => item.FilePath)
                </td>
                <td>@item.CreatedTime.ToString("yyyy-MM-dd HH:mm:ss")</td>
                <td>
                    <a asp-action="Restore"  asp-route-filePath="@item.FilePath"
                       class="btn btn-success btn-sm">
                        <i class="bi bi-trash"></i> 还原
                    </a>
                </td>
            </tr>
        }
    </tbody>
</table>